﻿CREATE FUNCTION [sp_ssiscatalog].[events]
(
		@exec_id			BIGINT												/*Specify which execution we want to return information for*/
)
RETURNS TABLE
AS
RETURN	
		SELECT	[ResultSet]=N'EVENTS',em.[event_message_id],em.[message_time],em.[message],em.[package_name],em.[event_name],em.[message_source_name],em.[package_path],em.[execution_path],emc.[event_message_context_xml]
		FROM	[$(SSISDB)].[catalog].[event_messages] em 
		CROSS APPLY [sp_ssiscatalog].[get_event_message_context_as_XML](em.[event_message_id])emc
		WHERE	em.[operation_id] = @exec_id